package com.zmn.oms.dubbo.impl.wallquotation;

import com.alibaba.fastjson.JSON;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.oms.common.dio.wallquotation.WallQuotationDIO;
import com.zmn.oms.common.dio.wallquotation.WallQuotationDetailDIO;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.dubbo.interfaces.wallquotation.WallQuotationModifyRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.zmn.business.interfaces.wallquotation.WallQuotationBService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * 墙面订单修改远程服务
 *
 * @author chengguang
 * @date 2022/05/24
 */
@DubboService(version = DubboConsts.INTERFACE_VERSION, validation = "true")
@Slf4j
public class WallQuotationModifyRemoteServiceImpl implements WallQuotationModifyRemoteService {

    @Resource
    private WallQuotationBService wallQuotationBService;

    @Override
    public ResponseDTO<Boolean> confirmWallQuotation(WallQuotationDIO wallQuotationDIO) {

        try {
            log.info("确认报价接口#confirmWallQuotation dio={}", JSON.toJSONString(wallQuotationDIO));
            return ResponseDTO.success(wallQuotationBService.confirmWallQuotation(wallQuotationDIO));
        } catch (OmsBaseException e) {
            return ResponseDTO.fail(e.getMessage());
        } catch (Exception e) {
            log.error("确认报价失败#confirmWallQuotation,{}", e.getMessage(), e);
            return ResponseDTO.fail("确认报价失败");
        }
    }

    @Override
    public ResponseDTO<Boolean> addWallQuotationDetail(WallQuotationDetailDIO wallQuotationDetailDIO) {

        try {
            log.info("保存报价信息接口#addWallQuotationDetail dio={}", JSON.toJSONString(wallQuotationDetailDIO));
            return ResponseDTO.success(wallQuotationBService.addWallQuotationDetail(wallQuotationDetailDIO));
        } catch (OmsBaseException e) {
            return ResponseDTO.fail(e.getMessage());
        } catch (Exception e) {
            log.error("保存报价信息失败,{}", e.getMessage(), e);
            return ResponseDTO.fail("保存报价信息失败");
        }
    }

}
